#include<bits/stdc++.h>
using namespace std;
#define int long long
int T,n,m,L,V;
struct car{
    int d,v,a;
}C[100005];
int p[100005],vis[100005];
struct node{
    int l,r;
    node(){}
    node(int l,int r):l(l),r(r){}
    bool operator < (const node & B) const {
        if(r==B.r)return l<B.l;
        return r<B.r;
    }
};
vector<node>D1;
struct point{
    int id,x,tp;//x:id,tp:1 in,0 out
    point(){}
    point(int id,int x,int tp):id(id),x(x),tp(tp){}
    bool operator < (const point & B) const {
        if(x==B.x)return tp>B.tp;
        return x<B.x;
    }
};
vector<point>D2;
set<int>s;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        D1.clear();D2.clear();
        s.clear();
        for(int i=1;i<=n;i++){
            cin>>C[i].d>>C[i].v>>C[i].a;
            int d=C[i].d,v=C[i].v,a=C[i].a;
            if(v<=V&&a<=0)continue;
            if(v>V&&a>=0){
                D1.push_back(node(d,L));
                continue;
            }
            if(v==V&&a>0){
                D1.push_back(node(d+1,L));
                continue;
            }
            if(a>0){
                int tmp=(V*V-v*v)/(2*a);
                D1.push_back(node(d+tmp+1,L));
            }
            else {
                int tmp=(V*V-v*v)/(2*a);
                if(tmp>=L)D1.push_back(node(d,L));
                else if((V*V-v*v)%(2*a)==0)D1.push_back(node(d,d+tmp-1));
                else D1.push_back(node(d,d+tmp));
            }
        }
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=0;i<D1.size();i++){
            int l=D1[i].l,r=D1[i].r;
            if(l>p[m]||r<p[1])continue;
            int lpos=lower_bound(p+1,p+m+1,l)-p,rpos=upper_bound(p+1,p+m+1,r)-p;
            if(lpos>=rpos)continue;
            D2.push_back(point(i,lpos,1));
            D2.push_back(point(i,rpos-1,0));
        }
        sort(D2.begin(),D2.end());
        cout<<D2.size()/2<<" ";
        int ans=0;
        for(int i=0;i<D1.size();i++)vis[i]=0;
        for(int i=0;i<D2.size();i++){
            int tp=D2[i].tp;
            if(tp==1)s.insert(D2[i].id);
            else{
                if(vis[D2[i].id])continue;
                ans++;
                for(auto x:s){
                    vis[x]=1;
                }
                s.clear();
            }
        }
        cout<<m-ans<<'\n';
    }
    return 0;
}